package org.ucn.dmaa0914.temadesign.group2.testLayer;

import org.ucn.dmaa0914.temadesign.group2.modelLayer.PersonContainer;
import org.ucn.dmaa0914.temadesign.group2.modelLayer.Person;

import static org.junit.Assert.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

/**
 * The test class PersonContainerTest.
 *
 * @author  (your name)
 * @version (a version number or a date)
 */
public class PersonContainerTest
{
    /**
     * Default constructor for test class PersonContainerTest
     */
    public PersonContainerTest()
    {
    }

    /**
     * Sets up the test fixture.
     *
     * Called before every test case method.
     */
    @Before
    public void setUp()
    {
    }

    @Test
    public void testContainer()
    {
        assertNotNull(PersonContainer.instance);
        
        Person p1 = new Person("John", "Giggedy Street 21", 47587, "Washington DC", "+0-557845-555-454578", "giggedy@gmail.com");
        Person p2 = new Person("Lars", "Giggedy Street 241", 447, "Washington DC", "+0-557845-555-454478", "lars89@gmail.com");
                
        PersonContainer.instance.addPerson(p1);
        PersonContainer.instance.addPerson(p2);
        
        assertTrue(PersonContainer.instance.containsPerson(p1));
        assertTrue(PersonContainer.instance.containsPerson(p2));
        
        assertNotNull(PersonContainer.instance.findPerson(p1.getId()));
        assertNotNull(PersonContainer.instance.findPerson(p2.getId()));
        
        assertNotNull(PersonContainer.instance.getPerson("+0-557845-555-454578"));
        assertNotNull(PersonContainer.instance.getPerson("+0-557845-555-454478"));
        
        assert(PersonContainer.instance.containsPerson(p2));
        
        PersonContainer.instance.deletePerson(p2);
        
        assertTrue(PersonContainer.instance.containsPerson(p1));
        assertFalse(PersonContainer.instance.containsPerson(p2));
    }
    
    /**
     * Tears down the test fixture.
     *
     * Called after every test case method.
     */
    @After
    public void tearDown()
    {
    }
}
